#include <..\utility.au3>

; TODO:
;  - Pixel detection if dialog is already open
;  - Pixel detection of each skill+sub.

;Time to (fuzzy)sleep after each click
$clickSleep = 250

Func openwindow()
	Send("s")
	fuzzysleep($clickSleep)
EndFunc

;1-4 - skills 1-4
;5-6 - left and right
;7-9 - passives
Func selectSkillType($skill)
	switch $skill
		case "5" 	; left
			fuzzyclick("left", 750, 210)
		case "6"	; right
			fuzzyclick("left", 1135, 210)
		case "1"
			fuzzyclick("left", 750, 380)
		case "2"
			fuzzyclick("left", 1135, 380)
		case "3"
			fuzzyclick("left", 750, 529)
		case "4"
			fuzzyclick("left", 1135, 529)
		case "7"   ;passive1
			fuzzyclick("left", 782, 683)
		case "8"   ;passive2
			fuzzyclick("left", 963, 679)
		case "9"   ;passive3
			fuzzyclick("left", 1127, 678)
	EndSwitch
	fuzzysleep($clickSleep)
EndFunc

;1-4
Func selectSkill($numToPick,$numInRow=4)
	$offset = 0
	if($numInRow=3) Then
		$offset = 77
	endif

	switch $numToPick
		case "1"
			fuzzyclick("left", 740+$offset, 210)
		case "2"
			fuzzyclick("left", 885+$offset, 210)
		case "3"
			fuzzyclick("left", 1026+$offset, 210)
		case "4"
			; can't have 3+4
			if($offset > 0 ) Then
				return 0
			EndIf
			fuzzyclick("left", 1168+$offset, 210)
	EndSwitch
	fuzzysleep($clickSleep)
EndFunc

Func selectRune($rune)
	switch $rune
		case "1"
			fuzzyclick("left", 595, 438)
		case "2"
			fuzzyclick("left", 740, 438)
		case "3"
			fuzzyclick("left", 885, 438)
		case "4"
			fuzzyclick("left", 1026, 438)
		case "5"
			fuzzyclick("left", 1168, 438)
		case "6"
			fuzzyclick("left", 1322, 438)
	EndSwitch
	fuzzysleep($clickSleep)
EndFunc

;1-15 - WD has 15, do others have more/less?
Func selectPassiveSkill($num)
	$row=Ceiling($num/4) - 1
	$col=($num-($row*4))-1

	$offset=0
	if($num>=13) then
		$offset=106
	EndIf

	$x = 575 + ($col*210)
	$y = 427 + ($row*100)
	fuzzyclick("left",$x+$offset, $y)

EndFunc

Func clickAccept()
	fuzzyclick("left", 840, 822)
	fuzzysleep($clickSleep)
EndFunc

Func clickCancel()
	fuzzyclick("left", 1067, 822)
	fuzzysleep($clickSleep)
EndFunc

Func scrollLeft($num=1)
	For $i=1 To $num
		fuzzyclick("left", 565,206)
		fuzzysleep(200)
	Next
EndFunc

Func scrollRight($num=1)
	For $i=1 To $num
		fuzzyclick("left", 1347,206)
		fuzzysleep(200)
	Next
EndFunc

